package com.shigen.demo.config;

import java.util.List;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class DefaultApplicationRunner implements ApplicationRunner, Ordered {

  @Override
  public void run(ApplicationArguments args) throws Exception {
    // 传递给应用程序的原始参数
    String[] sourceArgs = args.getSourceArgs();
    log.info("sourceArgs: {}", sourceArgs);
    // 获得选项的名称
    Set<String> optionNames = args.getOptionNames();
    log.info("optionNames: {}", optionNames);
    // 所有的无选项参数
    List<String> nonOptionArgs = args.getNonOptionArgs();
    log.info("nonOptionArgs: {}", nonOptionArgs);
  }

  @Override
  public int getOrder() {
    return Integer.MIN_VALUE + 2;
  }
}
